<?php defined('SYSPATH') or die('No direct script access.');

abstract class Controller_Template extends Kohana_Controller_Template {
	public $template = "";
	
	public function before()
	{
		parent::before();
	}
	
	public function load_sid()
	{
		$sid = Session::instance() -> get('sid', NULL);	
		if($sid == NULL)
		{
			$retinfo =  Response::factory();
			$retinfo -> status(401);
			$retinfo -> body('未登录');
			
			return false;
		}
		$this->sid = $sid;
		return true;
	}

	public function set_user($user)
	{
		Session::instance() -> set('user',$user);
	}
	
	public function get_user()
	{
		return Session::instance() -> get('user', NULL);
	}
	
	public function set_sid($sid)
	{
		Session::instance() -> set('sid', $sid);
	}

	public function get_sid()
	{
		return Session::instance() -> get('sid');
	}
	public function get_username()
	{
		$user = $this->get_user();
		if(!$user)
			return 'Guest';
		else
			return $user; 
	}
	
}
